#include <msp430.h> 
#include<stdlib.h>

#include"nrf2401.h"
#include"lcd1602.h"


#pragma vector = PORT1_VECTOR
__interrupt void Port1_ISR(void){
    P6OUT=~P6OUT;
    delay_ms(200);
    P6OUT=~P6OUT;
    P1IFG &= 0;
    delay_ms(200);
}

void main(){
    WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer

    Clock_Init();
    delay_ms(2000);
    init_spi();



    NRF2401_init();
    init();
    P6DIR=0xff;
    P6OUT=0x00;
    //unsigned char tx_buf[32]="Hello,world,Hell,World!";
    unsigned char *rx_buf=(unsigned char *)malloc(sizeof(unsigned char)*32);
    U0RXBUF=0;
    rx_buf[0]='e';
    unsigned char status1=0;
    while(1){

        status1=0;
                setRX();

                status1=recv(rx_buf);
                if(status1){
                    P6OUT=0xf0;
                    for(status1=0;status1<16;status1++){
                        wc(0x80+status1);
                        wd(rx_buf[status1]);
                    }
                }

        delay_ms(1000);
    }

}
